package com.ymatou.iapi.push.testcase;

import com.ymatou.iapi.push.parameter.decomposeBean;
import com.ymatou.iapi.push.parameter.pushBean;
import com.ymatou.iapi.push.parameter.Enum.AppIdType;
import com.ymatou.iapi.push.parameter.Enum.GetuiProvinceType;
import com.ymatou.iapi.push.parameter.Enum.PhoneType;
import com.ymatou.iapi.push.parameter.Enum.PushNetWorkType;
import com.ymatou.iapi.push.parameter.Enum.PushToAllBindClientType;
import com.ymatou.iapi.push.parameter.Enum.SendType;
import com.ymatou.iapi.push.parameter.Enum.UserSystemType;
import com.ymatou.iapi.push.service.decomposeCall;
import com.ymatou.iapi.push.service.pushCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.junit.*;
import org.junit.experimental.categories.Category;
/**
*APNs分解任务job
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_decompose{
	private static decomposeBean decomposeBean;
	private static decomposeCall decomposeCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("APNs分解任务job");
	}
	private pushBean initPushBean() {
		pushBean pushBean=new pushBean();
		pushBean.setA(AppIdType.ShenqiBuyer);
		//marktingFlag 是否是营销类消息
		pushBean.setMk(false);
		//phoneType 发送到指定手机类型
		pushBean.setSp(PhoneType.iOS);
		//badgeNum  iOS显示的图标数字
		pushBean.setBn(0);
		//messageTitle 消息标题
		pushBean.setMt("Hello,world");
		//messageBody 消息文本
		pushBean.setMb("Hello123");
		//pushToAllBindClientType 推送给所有跟此UserId绑定的客户端方式
		pushBean.setPa(PushToAllBindClientType.Newest);
		//payLoad 消息透传
		pushBean.setPl("{\"PushType\":\"123\"}");
		//isSendMessageTitle  发是否发送消息标题
		pushBean.setSmt(true);
		//offlineExpireSecondTime 当无法及时推送给用户时，最多存储时间(秒)
		pushBean.setEs(0);
		//netWorkType 在何种网络状态下发送(默认All)
		pushBean.setNt(PushNetWorkType.All);
		//key
		pushBean.setK("notify-85464298-e0dd-42e7-858f-4cd3ae5c8449");
		//userSystemType
		pushBean.setUst(UserSystemType.YmatouUser);
		//sendType 发送类型
		pushBean.setS(SendType.ToSingle);
		pushBean.setSu(20238699);
		pushBean.setT(GetuiProvinceType.All);
		pushBean.setDi("0B1CAAC5-EFAE-4C75-8641-35D689A4AD52");
		return pushBean;
	}
	private void push(pushBean pushBean) throws ClientProtocolException, IOException {
		pushCall pushCall=new pushCall();
		pushCall.setData(pushBean);
		pushCall.callService();			
	}
	@Before
	public void caseUp() {
		decomposeBean=new decomposeBean();
		decomposeCall=new decomposeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(decomposeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_decompose_001() {
		Logger.start(true,"APNs分解任务job");
		try {
			//decomposeCall.setData(decomposeBean);
//			for(int i=0;i<100;i++) {
//				pushBean p = initPushBean();
//				push(p);
//			}
			decomposeCall.callService();			
			Logger.verifyEquals("ok", decomposeCall.getReturnData(), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}